home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 687 < prev    next >
Text File  |  1996-08-06  |  1KB  |  34 lines

  1. Newsgroups: comp.std.c
  2. Path: blackbush.xlink.net!slsv6bt!news
  3. From: kanze@lts.sel.alcatel.de (James Kanze US/ESC 60/3/141 #40763)
  4. Subject: Re: Initializing a variable in terms of itself
  5. In-Reply-To: tim@franck's message of 1 Apr 1996 21:53:57 GMT
  6. Message-ID: <KANZE.96Apr2171323@slsvgqt.lts.sel.alcatel.de>
  7. Sender: news@lts.sel.alcatel.de
  8. Organization: GABI Software, Sarl.
  9. References: <4jpj9l$ik9@cnn.Princeton.EDU>
  10. Date: 02 Apr 1996 15:13:23 GMT
  11.  
  12. In article <4jpj9l$ik9@cnn.Princeton.EDU> tim@franck (Tim Hollebeek)
  13. writes:
  14.  
  15. |> Just out of curiosity, is this legal?
  16.  
  17. |> int main() {
  18. |>     int x = x;
  19. |>     return 0;
  20. |> }
  21.  
  22. No, it is undefined behavior, because you are accessing a variable
  23. before having initialized it.
  24.  
  25. The reference to `x' in the initialization expression is not, per se,
  26. illegal.  The variable is declared, and available for use, as soon as
  27. the compiler sees the `=' sign.
  28. -- 
  29. James Kanze         Tel.: (+33) 88 14 49 00        email: kanze@gabi-soft.fr
  30. GABI Software, Sarl., 8 rue des Francs-Bourgeois, F-67000 Strasbourg, France
  31. Conseils, Θtudes et rΘalisations en logiciel orientΘ objet --
  32.                 -- A la recherche d'une activitΘ dans une region francophone
  33.  
  34.